package com.zxy.servlet;

import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;

import java.io.IOException;
@WebServlet("/servletA")
public class ServletA extends HttpServlet {
    @Override
    public void service(ServletRequest req, ServletResponse resp) throws ServletException, IOException {
        System.out.println("servletA 执行了");
//        请求转发给ServletB
//        获得请求转发器
        RequestDispatcher requestDispatcher = req.getRequestDispatcher("servletB");
//        让请求转发器做出转发动作
        requestDispatcher.forward(req,resp);
    }
}
